//
//  DynamicCell.m
//  TheRoadAD
//
//  Created by baixue on 16/8/29.
//  Copyright © 2016年 baixue. All rights reserved.
//

#import "DynamicCell.h"
#import "DynamicModel.h"

@implementation DynamicCell

- (void)awakeFromNib {
    
    //适配
    _headImg.sd_layout
    .topSpaceToView(self.contentView,10)
    .leftSpaceToView(self.contentView,10)
    .widthIs(40*Screen_Width/320)
    .heightIs(40*Screen_Width/320);
    
    _userName.sd_layout
    .topSpaceToView(self.contentView,15)
    .leftSpaceToView(_headImg,10);
    
    _timer.sd_layout
    .topSpaceToView(_userName,2)
    .leftEqualToView(_userName);
    
    _pictureImg.sd_layout
    .topSpaceToView(_headImg,10)
    .leftSpaceToView(self.contentView,0)
    .rightSpaceToView(self.contentView,0)
    .heightIs(200 * Screen_Height/736);
    
    _content.sd_layout
    .topSpaceToView(_pictureImg,10)
    .autoHeightRatio(0)
    .leftSpaceToView(self.contentView,15)
    .rightSpaceToView(self.contentView,15);
    
    [_content setSingleLineAutoResizeWithMaxWidth:Screen_Width-20];

    
}

-(void)drawRect:(CGRect)rect{
    [super drawRect:rect];
    _headImg.layer.cornerRadius = _headImg.size.height/2;
    _headImg.layer.masksToBounds = YES;
}


-(void)setModel:(DynamicModel *)model{
    
    
    
    _headImg.image = [UIImage imageNamed:model.headImg];
    _userName.text = model.userName;
    _timer.text = model.timer;
    _pictureImg.image = [UIImage imageNamed:model.pictureImg];
    _content.text = model.content;
    
    
    [self setupAutoHeightWithBottomView:_content bottomMargin:10];
   
    

    
}

@end
